package cn.edu.zut.controller;

import cn.edu.zut.domain.News;
import cn.edu.zut.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private NewsService service;
    @RequestMapping("/findAll.do")
    public @ResponseBody List<News> findAll() {
        List<News> list =service.findAll();
        return list;
    }
    @RequestMapping("/delete.do")
    public @ResponseBody void deleteById(int _id){
        service.deleteById(_id);
    }

    @RequestMapping("/insertOne.do")
    public  @ResponseBody void insertOne(String contestId,String head,String date,String brief,
                                         String t0,String t1,String t2,String t3,String t4,
                                         String t5,String t6,String t7,String t8,String t9,
                                         String t10,String t11,String t12) throws Exception{
        News contact=new News(0,contestId,head,date,brief,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12);
        service.insertOne(contact);
    }


}
